<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.min.js"></script>
</head>
<body>
    <div>
        <button>发送GET请求</button>
    </div>

    <script>
        const btns=document.querySelectorAll('button');

        btns[0].onclick=function(){
            //创建实例对象
            const duanzi=axios.create({
                baseURL: 'https://api.apiopen.top',
                timeout:2000
            });
            //创建多个实例对象，可以和服务器一一对应
            const another=axios.create({
                baseURL: 'https://b.com',
                timeout:2000
            });

            //duanzi 与 axios 对象的功能几近一样
            duanzi.get('/getJoke').then(response=>{
                console.log(response);
            })
        }
    </script>
</body>
</html>
